package com.example.controller;

import com.example.User;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/12/31  10:04
 */
@RestController
@ConfigurationProperties(prefix = "user")
public class KtController {
    @Value("${name}")
    private String name;
    @Value("${age}")
    private int age;

    @Resource
    private User user;
    @GetMapping("/test")
    public String test() {
        return "hello spring boot";
    }
    @GetMapping("/test2")
    public String test2() {
        return "name="+name+",age="+age;
    }

    @GetMapping("/test3")
    public String test3() {
        return "name="+user.getName()+",age="+user.getAge();
    }
}
